package com.ljxt.dt.dao.purchasingmanagementdao.impl;

import com.alibaba.druid.util.ResultSetConsumer;
import com.ljxt.dt.dao.purchasingmanagementdao.PurchaseDetailDao;
import com.ljxt.dt.domain.GoodsInfo;
import com.ljxt.dt.domain.PurchaseDetail;
import com.ljxt.dt.domain.PurchaseInfo;
import com.ljxt.dt.domain.SupplierInfo;
import com.ljxt.dt.util.DaoUtil;
import com.ljxt.dt.util.xhq.ClassUtil;
import com.ljxt.dt.util.xhq.JdbcUtils;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 采购明细表的映射
 * @author 徐浩钦
 * @version 1.0.0
 * @date 2020/5/11 15:19
 * @copyright 老九学堂T11
 */
public class PurchaseDetailDaoImpl implements Serializable, PurchaseDetailDao{

    @Override
    public List<PurchaseDetail> selectAll(int pageIndex, int pageSize) {
        return null;
    }

    @Override
    public List<GoodsInfo> selectGoodsByPurchaseId(String id) {
        // 根据
        String sql = "select * from goods_info where id in(\n" +
                "\tselect goods_id from purchase_detail where order_no = ?)";
        // 参数
        Object[] parameter = {id};

        return JdbcUtils.selectAll(sql,null,null,GoodsInfo.class,parameter);
    }

    @Override
    public SupplierInfo selectSupplierInfoByGoods(int id) {
        String sql = "select * from supplier_info where id = (\n" +
                "select supplier_id from supplier_goods where goods_id = ?)";
        Object[] obj = {id};
        return JdbcUtils.selectAll(sql,1,1,SupplierInfo.class,obj).get(0);
    }

}
